package com.imooc.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class MyBean {

    private AnotherBean bean1;

    private AnotherBean bean2;

    @Autowired
    private AnotherBean bean3;

    @Autowired
//    @Qualifier("stringList")
    private List<String> stringList;

    @Autowired
    private Map<String,Integer> stringIntegerMap;

    @Value("bar")
    private String cardName;

    @Autowired
    private ApplicationContext context;

    @Autowired
    public MyBean(AnotherBean bean1) {
        this.bean1 = bean1;
    }

    public AnotherBean getBean2() {
        return bean2;
    }

    @Autowired
    public void setBean2(AnotherBean bean2) {
        this.bean2 = bean2;
    }

    public List<String> getStringList() {
        return stringList;
    }

    public void setStringList(List<String> stringList) {
        this.stringList = stringList;
    }

    public Map<String, Integer> getStringIntegerMap() {
        return stringIntegerMap;
    }

    public void setStringIntegerMap(Map<String, Integer> stringIntegerMap) {
        this.stringIntegerMap = stringIntegerMap;
    }

    public ApplicationContext getContext() {
        return context;
    }

    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    @Override
    public String toString() {
        return "MyBean{" +
                "bean1=" + bean1 +
                ", bean2=" + bean2 +
                ", bean3=" + bean3 +
                ", cardName=" + cardName +
                '}';
    }
}
